<?php

class tsw_cloud implements ThermdSingleWidget
{
  public function drawWidget($io,$x,$y)
  {	
    $black = imagecolorallocate($io,0,0,0);
    // check the cloud cover - if this comes back as N/A then just show the base
    $cc = ThermdStats::ts_cloudCoverCheck();
  
    // x = 418, y = 139
    if($cc=="N/A")
    {
  		$cb = ThermdStats::ts_readCurrent(ThermdStats::$cloudbase_log_id,0);
  		if($cb!==FALSE)
  		{
  			$cbimg = imagecreatefrompng(ThermdStats::$thermosrc.'cb.png');
  			
  			imagestring($io,3,$x+4,$y,"Cloud Base",$black);
  			imagecopy($io,$cbimg,$x+22,$y+16,0,0,29,24);
  			imagestring($io,2,$x+20,180,$cb.' M',$black);
  		}
		} else {
      // didn't come back as N/A so OK to add the icon!
			$cbimg = imagecreatefrompng(ThermdStats::$thermosrc.str_replace(' ','',strtolower($cc)).'.png');
			
			imagestring($io,3,$x,$y,"Cloud Cover",$black);
			imagecopy($io,$cbimg,$x+13,$y+14,0,0,48,28);
			imagestring($io,2,$x+20,$y+41,$cc,$black);
    }
  }
}

?>